package com.huo.thread.createthreaddemo;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableDemo implements Callable<String> {

    @Override
    public String call() throws Exception {
        return "test";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CallableDemo cd = new CallableDemo();
        FutureTask<String> task = new FutureTask<String>(cd);
        Thread t = new Thread(task);
        t.start();
        String str = task.get();
        System.out.println(str);
    }
}
